package com.hongguan.oms.web.plan;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jxl.write.WritableWorkbook;

import org.springframework.web.servlet.view.document.AbstractJExcelView;

import com.hongguan.oms.domain.plan.PlanInfoModel;
import com.hongguan.oms.service.plan.JxlWriter;

public class ExportPlanView extends AbstractJExcelView{
	
	protected void buildExcelDocument(
			Map model, WritableWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
			throws Exception{
		PlanInfoModel plan=(PlanInfoModel)model.get("plan");
		List<Map<String, Object>> listItem1=(List<Map<String, Object>>)model.get("listItem1");
		List<Map<String, Object>> listItem2=(List<Map<String, Object>>)model.get("listItem2");
		String fileName = plan.getPlanName() + ".xls";
		fileName = new String(fileName.getBytes("GBK"), "iso-8859-1");
		JxlWriter excelWriter=new JxlWriter();
		excelWriter.writeExcel(workbook, plan, listItem1, listItem2);
//		response.setContentType("application/x-msdownload");
		response.setHeader("Content-disposition", "attachment; filename=" + fileName);
	}
	
	
}
